// pages/pay/index.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    // userAddress:{},
    goodsList:[],
    // choseAll:false,
    allPrice:0,
    choseNum:0
  },

  cartList:[],

  onShow(options){
    const goods =wx.getStorageSync('cart');
    this.cartList =goods;
   
    this.jiSuanAllPrice();   

  }, 

// 计算总价
jiSuanAllPrice(){
  var price =0;
  var num =0;
  // 遍历 this.cartList.every(v=>v.is_promote);
 const chostArr =this.cartList.filter(v=>v.is_promote);
  for (let i = 0; i < this.cartList.length; i++) {
    if(this.cartList[i].is_promote===true){
      price =price+this.cartList[i].goods_price*this.cartList[i].num;
      num =num+this.cartList[i].num;
    }
  }
this.setData({
  goodsList:chostArr,
  allPrice:price,
  choseNum:num
})
},

// 结算
handleJieSan(){


}
})